//var jq=jQuery.noConflict();

var debugctrl = false;

<<<<<<< HEAD
//全局变量(单例)

var objGlobalVariable;

$(document).ready(function(){
    
        objGlobalVariable = new ProxySingletonCreate();
	objGlobalVariable.objCusHmiUi.OnInitDlg();
	objGlobalVariable.objCusUpdateTopState.onInitData();
	
	setTimeout(function(){window.scrollTo(0,1)},100);
	
	//横屏start//
	resize();
	window.addEventListener("resize", resize);
	//横屏end//

	document.body.addEventListener('click',function(e){
		kaishi();//全屏显示start//
		objGlobalVariable.objCusEventHandle.secondMenuHide(e);	
		objGlobalVariable.objCusEventHandle.topMenuHide(e);
	},false);

	$("#top_left").click(function() {
		
		guanbi();
	}); 
	document.addEventListener("fullscreenchange", function () {
	
		fullscreenState.innerHTML = (document.fullscreen) ? "" : "not ";
	}, false);
	document.addEventListener("mozfullscreenchange", function () {
		
		fullscreenState.innerHTML = (document.mozFullScreen) ? "" : "not ";
	}, false);

	document.addEventListener("webkitfullscreenchange", function () {
		
		fullscreenState.innerHTML = (document.webkitIsFullScreen) ? "" : "not ";
	}, false);
		
	document.addEventListener("msfullscreenchange", function () {
		
		fullscreenState.innerHTML = (document.msFullscreenElement) ? "" : "not ";
	}, false);
	//全屏显示end//
	
	//button事件
	$("button").click(function(e) {
		//按钮事件处理－ID
		objGlobalVariable.objCusEventHandle.eventBtHandle(e);
	}); 
	//div事件
	$(".event_click").click(function(e) {
		//按钮事件处理－ID
		objGlobalVariable.objCusEventHandle.eventDivHandle(e);
	}); 
	
	$("input").focus(function(e) {
		//按钮事件处理－ID

		objGlobalVariable.objCusEventHandle.eventRecordInputHandle(e);
	}); 
	//触发connectWebsocket 连接websocket
	//document.getElementById("connectWebsocket").click();
	
	document.getElementById("connectWebsocket").click();
	
	
	/*手动按钮长按事件*/
	$(".cl_content_manual_window_btn").on({
		touchstart: function(e){
			
                        
			if(objGlobalVariable.rockerMotionCmd === 0)
			{
				objGlobalVariable.rockerMotionCmd=1;
				objGlobalVariable.intervalSendCmd=setInterval(function(){sendMotionCmd(e)},100);
			}
			else
			{
				stopManualTimer(e);
				objGlobalVariable.rockerMotionCmd=1;
				objGlobalVariable.intervalSendCmd=setInterval(function(){sendMotionCmd(e)},100);
			}
			
			e.preventDefault();
			
			return true;
		},
		touchmove: function(e){
			stopManualTimer(e);
			return true;
		},
		touchend: function(e){
			stopManualTimer(e);
			
			return true;
		},
		click: function(e){
			return true;
		}
	});

	/*垂直滑动*/
	$('.span2').slider({
		formatter: function(value) {
			return value;
		},
		min: 1,
		max: 100,
		step:1,
		value:1,
		handle:"square",
		id:"RC", 
		tooltip:"hide"
	});
								

	//本地手动
	$('#slider-3').slider({
		formatter: function (value) {
			return 'Current value: ' + value;
		}
	}).on('slide', function (slideEvt) {
	}).on('change', function (e) {  
		objGlobalVariable.objCusUpdateTopState.variable_local_manual_v= 100 - e.value.newValue;	
	});
	$("#slider-3").slider({
		reversed : true
	});
	
	//设备手动速率
	$('#slider-1').slider({
		formatter: function (value) {
			return 'Current value: ' + value;
		}
	}).on('slide', function (slideEvt) {

		//当滚动时触发
		//console.info(slideEvt);
		//获取当前滚动的值，可能有重复
		// console.info(slideEvt.value);
	}).on('change', function (e) {

		objGlobalVariable.objCusEventHandle.refreshSliderCmdHandle("slider-1",e.value.newValue);
		//当值发生改变的时候触发
		//console.info(e);
		//获取旧值和新值
		//console.info(e.value.oldValue + '--' + e.value.newValue);
 
	});
	
	//设备自动速率
	$('#slider-2').slider({
		formatter: function (value) {
			return 'Current value: ' + value;
		}
	}).on('slide', function (slideEvt) {

	}).on('change', function (e) {
		objGlobalVariable.objCusEventHandle.refreshSliderCmdHandle("slider-2",e.value.newValue);
	});


	//初始化速率
	$('#slider-1').slider('setValue', 20);
	$('#slider-2').slider('setValue', 20);
	$('#slider-3').slider('setValue', 50);

	objGlobalVariable.objCusUpdateTopState.variable_local_manual_v= 100 - $("#slider-3").val();
	//手动速度初始化
	//启动worker
	startWorker();
=======
/*
//全局变量(单例)
 
    function enableNoSleep() {
        noSleep.enable(); 
        document.removeEventListener('click', enableNoSleep, false);
    } // Enable wake lock. // (must be wrapped in a user input event handler e.g. a mouse or touch handler) 
        document.addEventListener('click', enableNoSleep, false); // ... // Disable wake lock at some point in the future. // (does not need to be wrapped in any user input event handler) 
    noSleep.disable();
*/
$(document).ready(function () {
   
    window.objGlobalManage = new ProxySingletonCreate();
    window.objGlobalManage.OnInit();
    
    /*
    setTimeout(function () {
        window.scrollTo(0, 1)
    }, 100);*/
    
    //var maps = new Map();
    //alert(typeof(maps));
    

    //

    if(document.cookie.indexOf("a=hello")==-1){

        var t=new Date(new Date().getTime()+2000);
        document.cookie="a=hello; expires="+t.toGMTString();

        //unfullScreen();
        window.location.href=window.location.href;
        window.location.reload;
        /*
        window.location.href=window.location.href;
        window.location.reload; 
        

        history.go(0);
        location.reload();
        location=location;
        location.assign(location);
        document.execCommand('Refresh');
        window.navigate(location);
        location.replace(location);
        document.URL=location.href;*/
        
        
     
    }else{
        
    }
    




    

    //横屏start//
    resize();
    window.addEventListener("resize", resize);
    //横屏end//
    
    window.onresize = function(){

        var pageManualShowState = "";
        pageManualShowState = $("#page_manual_m_manual").css("display");
        if (pageManualShowState === "block")
        {
            if(window.objGlobalManage.objCusUpdateTopState.loginState === enumTypeLoginResult.kLoginSuccess)
            {
                $("#func_manual").trigger("click");
            }
            
        }
    }

    document.body.addEventListener('click', function (e) {
        
        
        var currentElement = $(e.target);

        if(currentElement.attr("unfull") !== "1")
        {
             
            fullScreen();//全屏显示start//
            window.objGlobalManage.objCusEventHandle.secondMenuHide(e);
            window.objGlobalManage.objCusEventHandle.topMenuHide(e);
        }

    }, false);

    $(".c_unfull").click(function () {
        unfullScreen();
    });
    document.addEventListener("fullscreenchange", function () {

        fullscreenState.innerHTML = (document.fullscreen) ? "" : "not ";
    }, false);
    document.addEventListener("mozfullscreenchange", function () {

        fullscreenState.innerHTML = (document.mozFullScreen) ? "" : "not ";
    }, false);

    document.addEventListener("webkitfullscreenchange", function () {

        fullscreenState.innerHTML = (document.webkitIsFullScreen) ? "" : "not ";
    }, false);

    document.addEventListener("msfullscreenchange", function () {

        fullscreenState.innerHTML = (document.msFullscreenElement) ? "" : "not ";
    }, false);
    //全屏显示end//

    //button事件
    
    
    $("body").on("click","button",function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventBtHandle(e);
    });
    //div事件
    $("body").on("click",".event_click",function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventDivHandle(e);
    });
    $("body").on("click","input",function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventRecordInputHandle(e);
    });
    
    /*
     $("button").click(function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventBtHandle(e);
    });
    //div事件
    $(".event_click").click(function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventDivHandle(e);
    });
    $("input").click(function(e){
        //按钮事件处理－ID
        window.objGlobalManage.objCusEventHandle.eventRecordInputHandle(e);
    });*/
    
    
    //事件处理当前以及未来添加的，但是相对较慢，对摇杆绘图有影响，导致摇杆绘图很慢--End
    

    //触发connectWebsocket 连接websocket
    document.getElementById("connectWebsocket").click();


    /*手动按钮长按事件*/
    $(".cl_content_manual_window_btn").on({
        touchstart: function (e) {




            if (window.objGlobalManage.intervalSendCmd === 0)
            {
                window.objGlobalManage.intervalSendCmd = 1;
                window.objGlobalManage.intervalTimer = setInterval(function () {
                    sendMotionCmd(e)
                }, 100);
            } else
            {
                stopManualTimer(e);
                window.objGlobalManage.intervalSendCmd = 1;
                window.objGlobalManage.intervalTimer = setInterval(function () {
                    sendMotionCmd(e)
                }, 100);
            }

            e.preventDefault();

            return true;
        },
        touchmove: function (e) {
            stopManualTimer(e);
            return true;
        },
        touchend: function (e) {
            stopManualTimer(e);

            return true;
        },
        click: function (e) {
            return true;
        }
    });

    /*垂直滑动*/
    $('.span2').slider({
        formatter: function (value) {
            return value;
        },
        min: 1,
        max: 100,
        step: 1,
        value: 1,
        handle: "square",
        id: "RC",
        tooltip: "hide"
    });


    //本地手动
    $('#slider-3').slider({
        formatter: function (value) {
            return 'Current value: ' + value;
        }
    }).on('slide', function (slideEvt) {
    }).on('change', function (e) {
        window.objGlobalManage.objCusUpdateTopState.variable_local_manual_v = 100 - e.value.newValue;
    });
    $("#slider-3").slider({
        reversed: true
    });

    //设备手动速率
    $('#slider-1').slider({
        formatter: function (value) {
            return 'Current value: ' + value;
        }
    }).on('slide', function (slideEvt) {

        //当滚动时触发
        //console.info(slideEvt);
        //获取当前滚动的值，可能有重复
        // console.info(slideEvt.value);
    }).on('change', function (e) {

        window.objGlobalManage.objCusEventHandle.refreshSliderCmdHandle("slider-1", e.value.newValue);
        //当值发生改变的时候触发
        //console.info(e);
        //获取旧值和新值
        //console.info(e.value.oldValue + '--' + e.value.newValue);

    });

    //设备自动速率
    $('#slider-2').slider({
        formatter: function (value) {
            return 'Current value: ' + value;
        }
    }).on('slide', function (slideEvt) {

    }).on('change', function (e) {
        window.objGlobalManage.objCusEventHandle.refreshSliderCmdHandle("slider-2", e.value.newValue);
    });


    //初始化速率
    $('#slider-1').slider('setValue', 20);
    $('#slider-2').slider('setValue', 20);
    $('#slider-3').slider('setValue', 50);

    window.objGlobalManage.objCusUpdateTopState.variable_local_manual_v = 100 - $("#slider-3").val();

    //启动worker
    startWorker();
>>>>>>> dev
});



// 重设屏幕大小 start
function resize() {
<<<<<<< HEAD
	var body = document.getElementsByTagName('body')[0];
	var html = document.getElementsByTagName('html')[0];
	var width = html.clientWidth;
	var height =  html.clientHeight;
	var max = width > height ? width : height;
	var min = width > height ? height : width;
	body.style.width = max + "px";
	body.style.height = min + "px";
  }
// 重设屏幕大小 end
function sendMotionCmd(e){
	var targetElement = $(e.target);

	
	var targetId = targetElement.attr("id");
	/* 停止运行 */
	if(objGlobalVariable.rockerMotionCmd === 0)
	{
		return false;
	}

	var windowIsShow = getVisibilityState();

	//浏览器隐藏时停止发送
	if(windowIsShow === "visibilityState")
	{

	}
	else
	{
		stopManualTimer(e);
		return false;
	}

	//手动按钮样式添加边框
	$("#"+targetId).css("border","solid 2px #3d4e60");
	
	if(targetId === "id_content_manual_window_bt_forward")
	{
		
		/* 前 */
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_x=1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;

		
		cmdRowChild.move_y=0.0;
		cmdRowChild.move_rotate=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);

		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_back")
	{
		/*后 */

		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_x=-1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;
		cmdRowChild.move_y=0.0;
		cmdRowChild.move_rotate=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_left")
	{
		/*左*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_y=-1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;
		cmdRowChild.move_x=0.0;
		cmdRowChild.move_rotate=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_right")
	{
		/*右*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_y=1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;
		cmdRowChild.move_x=0.0;
		cmdRowChild.move_rotate=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_turnleft")
	{
		/*左转*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_rotate=1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;
		cmdRowChild.move_x=0.0;
		cmdRowChild.move_y=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_turnright")
	{
		/*右转*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.move_rotate=-1*objGlobalVariable.objCusUpdateTopState.variable_local_manual_v/100.0;
		cmdRowChild.move_x=0.0;
		cmdRowChild.move_y=0.0;
		cmdRowParent.manual_move = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	
	
}
function stopManualTimer(e){
	
	
	clearInterval(objGlobalVariable.intervalSendCmd);
	stopMotionCmd(e);
}

/* 停止 */
function stopMotionCmd(e){
	
	var targetElement = $(e.target);
	var targetId = targetElement.attr("id");
	//手动按钮样式
	$("#"+targetId).css("border","");

	if(objGlobalVariable.rockerMotionCmd === 1)
	{
		objGlobalVariable.rockerMotionCmd == 0;
	}

	if(targetId === "id_content_manual_window_bt_forward")
	{
		/* 前 */
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_back")
	{
		/* 后 */
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_left")
	{
		/*左*/ 

		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_right")
	{
		/*右*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_turnleft")
	{
		/*左转*/ 
		/* 前 */
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
	else if(targetId === "id_content_manual_window_bt_turnright")
	{
		/*右转*/ 
		var cmdRowParent = {};
		var cmdRowChild = {};
		cmdRowChild.parameter=0;
		cmdRowParent.manual_stop = cmdRowChild;
		var sendData=JSON.stringify(cmdRowParent);
		$("#manual_show_text").text(sendData);
		objGlobalVariable.objWebSocket.sendMessage(sendData);
	}
}
var g_objWorkers;
var g_msg_twinkle=0;
function startWorker()
{
	if(typeof(Worker)!=="undefined")
	{
		if(typeof(g_objWorkers)=="undefined")
		{
			g_objWorkers=new Worker("js/hmiworkers.js");
		}
		g_objWorkers.onmessage = function (event) {
			if(!debugctrl)
			{
				objGlobalVariable.objCusUpdateTopState.requestTopStateAll();
			}

			
			if(objGlobalVariable.objCusUpdateTopState.arrayMsg.length>0)
			{
				if(g_msg_twinkle%2 == 0)
				{
					$("#span_top_state_flag_msg").css("color","#ff0000");
				}
				else
				{
					$("#span_top_state_flag_msg").css("color","#ffffff");
				}
				g_msg_twinkle++;
			}
			else
			{
				$("#span_top_state_flag_msg").css("color","#ffffff");
			}
			
			if(g_msg_twinkle > 10)
			{
				g_msg_twinkle = 0;
			}
		};
	}
	else
	{
		document.getElementById("homes").innerHTML="Sorry, your browser does not support Web Workers...";
	}
}

function stopWorker()
{ 
	g_objWorkers.terminate();
=======
    var body = document.getElementsByTagName('body')[0];
    var html = document.getElementsByTagName('html')[0];
    var width = html.clientWidth;
    var height = html.clientHeight;
    var max = width > height ? width : height;
    var min = width > height ? height : width;
    body.style.width = max + "px";
    body.style.height = min + "px";
    
    /*手动界面 end*/
    var itemSize=document.body.clientHeight/6;
    var dataValue = itemSize.toString()+"px";

    $(".cl_content_manual_window_btn").css("width",dataValue);
    $(".cl_content_manual_window_btn").css("height",dataValue);
    $(".cl_content_manual_window_btn").css("margin","10px");

    $(".btn-circle").css("width",dataValue);
    $(".btn-circle").css("height",dataValue);
    
    var borderRadius=itemSize/2;
    var borderRadiusDataValue=borderRadius.toString()+"px";
    $(".btn-circle").css("border-radius",borderRadiusDataValue);
    $(".btn-circle").css("margin","10px");
}
// 重设屏幕大小 end
function sendMotionCmd(e) {
    window.objGlobalManage.objCusManualMode.pressKeysControlRun(e);
}
function stopManualTimer(e) {
    clearInterval(window.objGlobalManage.intervalTimer);
    window.objGlobalManage.intervalSendCmd = 0;
    stopMotionCmd(e);
}

/* 停止 */
function stopMotionCmd(e) {

    window.objGlobalManage.objCusManualMode.pressKeysControlStop(e);
}
var g_objWorkers;
var g_msg_twinkle = 0;

function startWorker()
{
    if (typeof (Worker) !== "undefined")
    {
        if (typeof (g_objWorkers) == "undefined")
        {
            g_objWorkers = new Worker("js/hmiworkers.js");
        }
        g_objWorkers.onmessage = function (event) {
            if (debugctrl)
            {
                return;
            }
            window.objGlobalManage.objCusUpdateTopState.requestTopStateAll();
            //顶部消息闪烁
            if (window.objGlobalManage.objCusUpdateTopState.arrayMsg.length > 0)
            {
                if (g_msg_twinkle % 2 == 0)
                {
                    $("#span_top_state_flag_msg").css("color", "#ff0000");
                } else
                {
                    $("#span_top_state_flag_msg").css("color", "#ffffff");
                }
                g_msg_twinkle++;
            } else
            {
                $("#span_top_state_flag_msg").css("color", "#ffffff");
            }
            //定时获取VMARK信息 
            if (window.objGlobalManage.request_vmark_info % 2 == 0)
            {
               window.objGlobalManage.objCusProtocol.func_get_vmark_debug_info();
            } 
            window.objGlobalManage.request_vmark_info++;
            //程序打开跳转
            window.objGlobalManage.objCusProgramMode.jumpProgramWindowHandle();
            
            

            if (g_msg_twinkle > 10)
            {
                g_msg_twinkle = 0;
            }
        };
    } else
    {
        document.getElementById("homes").innerHTML = "Sorry, your browser does not support Web Workers...";
    }
}

function stopWorker()
{
    g_objWorkers.terminate();
>>>>>>> dev
}
